package edu.gatech.volt2.drdoommgt.domain;
import java.util.ArrayList;
import java.util.List;

/**
 * This class represents medical information of a patient
 * 
 * @author Perron Jones
 */
public class MedicalInfo 
{

	private List<String> allergies;
	private Insurance insurance;
	private Pharmacy pharmacy;
	
	/**
	 * This default constructor sets the metadata of the medical information to
	 * customized default values.
	 */
	public MedicalInfo()
	{
		this.allergies= new ArrayList<String>();
		this.insurance= new Insurance();
		this.pharmacy= new Pharmacy();
	}
	
	/**
	 * This default constructor sets the metadata of the medical information to
	 * the information that is passed into it.
	 * 
	 * @param allergies the list of allergies of the patient
	 * @param insurance the insurance information
	 * @param pharmacy the pharmacy information
	 */
	public MedicalInfo(List<String> allergies, Insurance insurance, Pharmacy pharmacy)
	{
		this.allergies= (allergies == null ? new ArrayList<String>() : allergies);
		this.insurance= (insurance == null ? new Insurance() : insurance);
		this.pharmacy= (pharmacy == null ? new Pharmacy() : pharmacy);
	}
	
	/**
	 * This method creates a string representation of the medical information.
	 * 
	 * @return a string representation of the medical information
	 */
	public String toString()
	{
		String medInfo= "Allergies:\n" + this.viewAllergies() + "\n" + "\nInsurance:\n" + this.insurance.toString() +
			"\nPharmacy:\n" + this.pharmacy.toString() + "\n";
		
		return medInfo;
	}
	
	/**
	 * @param allergies the allergies to set
	 */
	public void setAllergies(List<String> allergies)
	{
		this.allergies = allergies;
	}
	
	/**
	 * @return the allergies
	 */
	public List<String> getAllergies()
	{
		return allergies;
	}
	
	/**
	 * This method creates a string representation of the list of allergies
	 * 
	 * @return a string representation of the list of allergies
	 */
	public String viewAllergies()
	{
		String allergies="";
		if(this.allergies.size() == 0)
		{
			allergies="none";
		}
		else
		{
			for(String allergy : this.allergies)
			{
				allergies+= allergy + "\n";
			}
		}
		return allergies;
	}
	
	/**
	 * @param insurance the insurance information to set
	 */
	public void setInsurance(Insurance insurance)
	{
		this.insurance = insurance;
	}
	
	/**
	 * @return the insurance information
	 */
	public Insurance getInsurance()
	{
		return insurance;
	}
	
	/**
	 * @param pharmacy the pharmacy information to set
	 */
	public void setPharmacy(Pharmacy pharmacy)
	{
		this.pharmacy = pharmacy;
	}
	
	/**
	 * @return the pharmacy information
	 */
	public Pharmacy getPharmacy()
	{
		return pharmacy;
	}
	
}
